import {
	createSSRApp
} from "vue";
import App from "./App.vue";
import stores, {useStore} from './stores'
import config from './config/index'
import constant from './util/const';
import Core from '@/core';
import XInput from '@/components/form/input';
import XSelect from '@/components/form/select';
import XDatetime from '@/components/form/datetime';
import XUploader from '@/components/form/uploader/index';
import XEmpty from '@/components/lib/empty';
import XBottom from '@/components/lib/bottom';
import XMain from '@/components/lib/main';
import XBox from '@/components/lib/box';
import XCell from '@/components/lib/cell';
import PrivacyModal from '@/pages/privacy.vue';

import Mixin from './mixin';

export function createApp() {
	const app = createSSRApp(App);
	app.use(stores)
	app.use(Core, {config, useStore, constant})

	if(uni.Helper.empty(uni.Cache.get("sessionId"))) {
		uni.Cache.set("sessionId", uni.Helper.genRandomStr(32), 24 * 60 * 60)
	}

	app.component("x-empty", XEmpty);
	app.component("x-input", XInput);
	app.component("x-select", XSelect);
	app.component("x-datetime", XDatetime);
	app.component("x-uploader", XUploader);
	app.component("x-bottom", XBottom);
	app.component("x-main", XMain);
	app.component("x-box", XBox);
	app.component("x-cell", XCell);
	app.component('PrivacyModal', PrivacyModal); // 统一隐私协议弹窗
	app.config.globalProperties['publicPath'] = "/static/image/";

	app.mixin(Mixin);
	return {
		app,
	};
}
